from langchain.memory import ConversationSummaryMemory
from langchain.chains import ConversationChain
import os

from langchain_community.llms.tongyi import Tongyi
os.environ["DASHSCOPE_API_KEY"] = "sk-9d8f1914800e497f8717144e860f99bc"
llm = Tongyi()
memory = ConversationSummaryMemory(llm=llm)
memory.save_context({"input": "你好"}, {"output": "什么事"})
chain = ConversationChain(
    llm=llm,
    memory=memory
)
res = chain.invoke("我想知道月亮到地球距离")
print(res)